<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/17
 * Time: 17:12
 */

namespace app\zucai\admin;
use app\admin\controller\Admin;
use app\common\builder\ZBuilder;
use think\Db;

class Notice extends Admin
{
//首页公告
    public function index(){
        if($this->request->post()){
            $data = Db::name('notice')->where('id',1)->update(['content'=>$_POST['content']]);
            if($data>0){
                return $this->success('更新成功');
            }else{
                return $this->error('更新失败');
            }
        }else{
            $data = Db::name('notice')->find();
            if($data['content']==''){
                $data['content']='公告内容';
            }
            return ZBuilder::make('form')
                ->addText('content', '公告内容')
                ->setFormData($data)
                ->fetch();
        }

    }
}